package com.dst.service.impl;

import com.dst.dao.PhoneMapper;
import com.dst.entity.Phone;
import com.dst.service.PhoneService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("phoneService")
public class PhoneServiceimpl implements PhoneService {
    @Autowired
    @Qualifier("phoneMapper")
    private PhoneMapper phoneMapper;

    @Override
    public List<Phone> selectAll() {
        List<Phone> phones = phoneMapper.selectAll();
        return phones;
    }

    @Override
    public void delete(int id) {
        phoneMapper.delete(id);
    }

    @Override
    public Phone selectById(int id) {
        Phone phone = phoneMapper.selectById(id);
        return phone;
    }

    @Override
    public void update(Phone phone) {
        phoneMapper.update(phone);
    }

    @Override
    public void insert(Phone phone) {
        phoneMapper.insert(phone);
    }

    @Override
    public void deleteBatch(int[] ids) {
        phoneMapper.deleteBatch(ids);
    }

    @Override
    public void deletePhone(int id) {
        phoneMapper.deletePhone(id);
    }

    @Override
    public PageInfo<Phone> selectLimitAll(int curpage, int pagesize) {
        PageHelper.startPage(curpage,pagesize);
        List<Phone> phones = phoneMapper.selectAll();
        PageInfo<Phone> phonePageInfo = new PageInfo<>(phones);
        return phonePageInfo;
    }


}
